package com.wondersgroup.app.appointment.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wondersgroup.core.frame.BaseController;
import com.wondersgroup.core.frame.CommonStatusResult;
import com.wondersgroup.core.service.BatchService;
import com.wondersgroup.core.util.ErrorMessageConstant;

@Controller
@RequestMapping("/batch")
public class BatchController extends BaseController{

	@Autowired
	private BatchService batchService;
	@RequestMapping(value="/queryDetail", method = RequestMethod.POST)
	@ResponseBody
	public CommonStatusResult queryBatch(
			@RequestParam(required=true, value="batchNo") String batchNo,
			@RequestParam(required=true,value="barcode") String barcode){

		if(!barcode.equals("6925303710156")&&!barcode.equals("6901209302220")&&!barcode.equals("6948195800309")){

			return CommonStatusResult.fail(ErrorMessageConstant.CODE_FAIL, null);
		}else if(batchNo==null||"".equals(batchNo)){
			return CommonStatusResult.fail(ErrorMessageConstant.CODE_FAIL, null);
		}else if(!batchNo.equals("20150728")&&!batchNo.equals("20150716044703")&&!batchNo.equals("20150815ks33")){
			return CommonStatusResult.fail(ErrorMessageConstant.CODE_FAIL, null);
		}
		Map<String, Object> result=batchService.findByBatchNo(batchNo,barcode);
		return CommonStatusResult.success(ErrorMessageConstant.CODE_SUCCESS, result);
		}
	    
		
	
}
